/**
* Author: fulishang
* Create Time  : 2016年8月21日,上午1:43:20
* Modify Time :
* Desc  : 
*/
package com.sam.si.dc.handler;

import java.io.File;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

@Component
public class HousekeepHandler {

	private Logger LOGGER = Logger.getLogger(HousekeepHandler.class);
	
	/**
	 * archive file after process
	 * @param filePath
	 */
	public void fileHousekeep(String filePath) {
		
		File dir = new File(filePath);
		File[] files = dir.listFiles();
		if (files == null) {
			LOGGER.info("Nothing to archived...");
			return;
		}			
		
		for (int i=0; i<files.length; i++) {
			LOGGER.info("Arching the file -- " + files[i]);

			if (files[i].isDirectory()) { //iter the folder
				fileHousekeep((files[i].getPath()));
			} else {
				files[i].delete();				
				LOGGER.info("Housekeep file successfully...!!!");
			}
			
		}	
	}
}
